package orchestration.businessprocess.execution;

import orchestration.businessprocess.model.BPArtifact;
import orchestration.businessprocess.model.BPArtifactId;


/**
 * A property contains a value, an id and a description of its content ( {@link BPArtifact})
 * @author  <a href="mailto:car.ferrarini@gmail.com">Carlo Ferrarini</a>
 */
public class Property{

	/**
	 * @uml.property  name="id"
	 */
	private long id;
	/**
	 * @uml.property  name="artifact"
	 * @uml.associationEnd  
	 */
	private BPArtifact artifact;
	/**
	 * @uml.property  name="value"
	 */
	private Object value;

	public Property(BPArtifact artifact) {
		this.artifact=artifact;
	}
	public String getName() {
		return artifact.getName();
	}
	
	public Class<?> getType(){
		return artifact.getType();
	}
	public Class<?> getComponentType(){
		return artifact.getComponentType();
	}
	/**
	 * @return
	 * @uml.property  name="value"
	 */
	public Object getValue() {
		
		return value==null?null:getType().cast(value);
	}

	/**
	 * @param value
	 * @uml.property  name="value"
	 */
	public void setValue(Object value) {
			this.value = value==null?null:getType().cast(value);
	}
	public BPArtifactId getArtifactId() {
		return artifact.getId();
	}
	/**
	 * @param id
	 * @uml.property  name="id"
	 */
	public void setId(long id) {
		this.id = id;
	}
	/**
	 * @return
	 * @uml.property  name="id"
	 */
	public long getId() {
		return id;
	}
}
